package cn.com.b2office.struts2.action;

import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import cn.com.b2office.domain.User;
import cn.com.b2office.service.CollectionService;

import com.opensymphony.xwork2.ActionSupport;

public class AddCollectionAction extends ActionSupport implements SessionAware {

	private static final long serialVersionUID = 1532226146994350901L;

	private String itemId = null;

	private Map session = null;

	private CollectionService collectionService = null;

	private String message = null;

	public String execute() throws Exception {
		User user = (User) session.get("user");
		if (user == null)
			message = "请先登录";
		else {
			collectionService.addCollection(itemId, user.getMemberId());
			message = "收藏成功";
		}
		return SUCCESS;
	}

	public void setCollectionService(CollectionService collectionService) {
		this.collectionService = collectionService;
	}

	public void setItemId(String itemId) {
		this.itemId = itemId;
	}

	public void setSession(Map session) {
		this.session = session;
	}

	public String getMessage() {
		return message;
	}

}
